import { getFormatterPrice } from '@const/filter'
// 批发销售订单列表页面tab状态
export const WHOLESALE_ORDER_STATUS = [
  {
    label: '待确认',
    value: 'voucherStatusNotConfirm'
  },
  {
    label: '待发货',
    value: 'voucherStatusNotDelivery'
  },
  {
    label: '部分发货',
    value: 'voucherStatusPartialShipment'
  },
  {
    label: '全部发货',
    value: 'voucherStatusAllShipment'
  },
  {
    label: '已完成',
    value: ''
  },
  {
    label: '已撤销',
    value: ''
  }
]
export const ORDER_STATUS_TEXT = {
  1: '待确认',
  2: '待发货',
  3: '部分发货',
  4: '全部发货',
  5: '已完成',
  6: '已撤销',
  7: '已删除'
}
// 产品大类
export const PRODUCT_CATEGORY = {
  1: '高值',
  2: '低值',
  3: '试剂',
  4: '设备',
  5: '低值'
}
// 管理分类
export const PRODUCT_MANAGE_CATEGORY = {
  1: '一类',
  2: '二类',
  3: '三类'
}
// 注册地
export const PRODUCT_REGISTER_TYPE = {
  1: '国产',
  2: '港澳台',
  3: '进口'
}

// 查询条件
export const SEARCH_FORM = [
  {
    key: 'hospitalName',
    title: '医疗机构',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'purchaseOrderCode',
    title: 'M平台销售订单编号',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'deliveryOrderCode',
    title: '配送商销售订单编号',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'createdAt',
    title: '提交时间',
    type: 'time',
    fieldname: ['startTime', 'endTime'],
    attr: {
      placeholder: '请选择',
      type: 'daterange',
      'start-placeholder': '开始时间',
      'end-placeholder': '结束时间',
      'default-time': ['00:00:00', '23:59:59'],
      'style': { width: '280px' }
      // pickerOptions: {
      //   disabledDate: time => {
      //     return time.getTime() >= Date.now() + 8.64e7
      //   }
      // }
    }
  }
]
// 批发销售订单列表表头
export const ORDER_COLUMNS = [
  {
    type: 'selection',
    selectable: row => row.purchaseOrderStatus === 1
  },
  {
    width: '200',
    prop: 'purchaseOrderCode',
    label: 'M平台销售订单编号',
    'show-overflow-tooltip': true
  },
  {
    width: '200',
    prop: 'deliveryOrderCode',
    label: '配送商销售订单编号',
    'show-overflow-tooltip': true
  },
  {
    prop: 'productSpecCount',
    minWidth: '100',
    label: '品规数',
    'show-overflow-tooltip': true
  },
  {
    prop: 'hospitalName',
    minWidth: '200',
    label: '医疗机构',
    'show-overflow-tooltip': true
  },
  {
    prop: 'orderTotalAmount',
    minWidth: '100',
    label: '销售金额',
    formatter: row => getFormatterPrice(row.orderTotalAmount || 0)
  },
  {
    prop: 'purchaseOrderStatus',
    minWidth: '100',
    label: '订单状态',
    formatter: row => ORDER_STATUS_TEXT[row.purchaseOrderStatus]
  },
  {
    prop: 'createdAt',
    minWidth: '200',
    label: '提交时间'
  },
  {
    width: '200',
    prop: 'action',
    label: '操作',
    fixed: 'right'
  }
]
// 批量确认基础信息
export const ORDER_BASE_INFO = {
  deliveryOrderCode: '配送商销售订单编号',
  purchaseOrderStatus: '订单状态',
  createdAt: '下单时间',
  hospitalName: '医疗机构',
  productSpecCount: '品规数',
  receiveAddress: '收货地址',
  linkMan: '联系人',
  linkPhone: '联系电话',
  orderTotalAmount: '订单金额'
}
// 批量确认订单列表表头
export const BATCH_TABLE_COLUMNS = [
  {
    width: '80',
    type: 'index',
    label: '序号'
  },
  {
    minWidth: '200',
    prop: 'orderItemCode',
    label: '订单明细编码',
    showTooltipWhenOverflow: true
  },
  {
    minWidth: '200',
    prop: 'deliveryProductCode',
    label: '配送商产品编码',
    showTooltipWhenOverflow: true
  }, {
    minWidth: '200',
    prop: 'deliveryProductName',
    label: '配送商产品名称',
    showTooltipWhenOverflow: true
  },
  {
    minWidth: '150',
    prop: 'specification',
    label: '规格',
    showTooltipWhenOverflow: true
  },
  {
    minWidth: '150',
    prop: 'productType',
    label: '型号',
    showTooltipWhenOverflow: true
  },
  {
    minWidth: '150',
    prop: 'manufacturer',
    label: '生产厂家',
    showTooltipWhenOverflow: true
  }, {
    minWidth: '200',
    prop: 'registrationNumber',
    label: '注册证号（或备案号）',
    showTooltipWhenOverflow: true
  },
  {
    width: '120',
    prop: 'category',
    label: '产品大类',
    formatter: row => PRODUCT_CATEGORY[row.category]
  },
  {
    width: '120',
    prop: 'price',
    label: '单价',
    formatter: row => getFormatterPrice(row.price || 0)
  }, {
    width: '180',
    prop: 'purchaseNum',
    label: '销售数量/单位',
    formatter: row => `${row.purchaseNum && row.unit ? `${row.purchaseNum}/${row.unit}` : row.purchaseNum || row.unit ? row.purchaseNum : ''}`
  },
  {
    width: '120',
    prop: 'detailAmount',
    label: '小计金额',
    formatter: row => getFormatterPrice(row.detailAmount || 0)
  },
  {
    minWidth: '120',
    prop: 'manageCategory',
    label: '管理分类',
    formatter: row => PRODUCT_MANAGE_CATEGORY[row.manageCategory]
  }, {
    width: '120',
    prop: 'registerType',
    label: '注册地',
    formatter: row => PRODUCT_REGISTER_TYPE[row.registerType]
  },
  {
    minWidth: '200',
    prop: 'provinceProductCode',
    label: '省平台产品编码',
    showTooltipWhenOverflow: true
  },
  {
    minWidth: '200',
    prop: 'itemCode',
    label: 'M平台产品编码',
    showTooltipWhenOverflow: true
  }
]
// 详情头部信息
export const TOP_INFO = [
  {
    key: 'purchaseOrderCode',
    value: '平台销售订单编号'
  },
  {
    key: 'deliveryOrderCode',
    value: '配送商销售订单编号'
  },
  {
    key: 'purchaseOrderStatus',
    value: '订单状态'
  },
  {
    key: 'createdAt',
    value: '下单时间'
  },
  {
    key: 'hospitalName',
    value: '医疗机构'
  },
  {
    key: 'productSpecCount',
    value: '品规数'
  },
  {
    key: 'receiveAddress',
    value: '收货地址'
  },
  {
    key: 'linkMan',
    value: '联系人'
  },
  {
    key: 'linkPhone',
    value: '联系电话'
  },
  {
    key: 'orderTotalAmount',
    value: '订单金额'
  }
]
// 详情table表头
export const TABLE_COLUMNS = [
  {
    label: '序号',
    type: 'index',
    width: 80
  }, {
    prop: 'orderItemCode',
    label: '订单明细编号',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'deliveryProductCode',
    label: '配送商产品编码',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'deliveryProductName',
    label: '配送商产品名称',
    minWidth: 200,
    'show-overflow-tooltip': true
  }, {
    prop: 'specification',
    label: '规格',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'productType',
    label: '型号',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'manufacturer',
    label: '生产厂家',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'registrationNumber',
    label: '注册证号（或备案号）',
    width: 170,
    'show-overflow-tooltip': true
  }, {
    prop: 'category',
    label: '产品大类',
    width: 150,
    formatter: row => PRODUCT_CATEGORY[row.category]
  }, {
    prop: 'price',
    label: '单价',
    width: 150,
    formatter: row => getFormatterPrice(row.price || 0)
  }, {
    prop: 'purchaseNum',
    label: '销售数量/单位',
    width: 150,
    formatter: row => `${row.purchaseNum && row.unit ? `${row.purchaseNum}/${row.unit}` : row.purchaseNum || row.unit ? row.purchaseNum : ''}`

  }, {
    prop: 'detailAmount',
    label: '小计金额',
    width: 150,
    formatter: row => getFormatterPrice(row.detailAmount || 0)
  }, {
    prop: 'provinceProductCode',
    label: '省平台产品编码',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'itemCode',
    label: 'M平台产品编码',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'storageCondition',
    label: '储存条件',
    width: 150
  }
]
// 部分发货详情table头部信息
// export const TABLE_TOP_INFO = [
//   {
//     label: '配送单号',
//     value: 'deliveryCode'
//   },
//   {
//     label: '配送时间',
//     value: 'createdAt'
//   },
//   {
//     label: '配送单数量',
//     value: 'medicalInstitution'
//   }
// ]
// 部分详情table列表表头
export const PART_DETAIL_COLUMNS = [
  {
    width: '40',
    prop: 'placeholder',
    fixed: 'left',
    type: 'expand'
  },
  {
    prop: 'cargo',
    label: '配送明细编号',
    width: 150
  }, {
    prop: 'deliveryProductCode',
    label: '配送商产品编码',
    width: 150
  }, {
    prop: 'deliveryProductName',
    label: '配送商产品名称',
    width: 150
  }, {
    prop: 'specification',
    label: '规格型号',
    width: 150,
    formatter: row => `${row.specification || row.productType ? `${row.specification} ${row.productType}` : ''}`
  }, {
    prop: 'category',
    label: '产品大类',
    width: 150
  }, {
    prop: 'batch',
    label: '批号',
    width: 150
  }, {
    prop: 'periodDate',
    label: '有效日期',
    width: 170
  }, {
    prop: 'sendNum',
    label: '配送单数量',
    minWidth: 160
  }, {
    prop: 'minUnit',
    label: '计量单位',
    width: 150
  },
  {
    prop: 'returnNum',
    label: '质检异常数量',
    width: 150
  },
  {
    prop: 'storageCondition',
    label: '储存条件',
    width: 150
  }, {
    prop: 'provinceProductCode',
    label: '省平台产品编码',
    width: 150
  }, {
    prop: 'itemCode',
    label: 'M平台产品编码',
    width: 150
  }
]
// 部分详情列表中的列表
export const PART_DETAIL_COLUMNS_INSIDE = [
  {
    label: '序号',
    type: 'index',
    width: 56
  }, {
    prop: 'udi',
    label: 'UDI',
    minWidth: 100,
    'show-overflow-tooltip': true
  }, {
    prop: 'mainCode',
    label: '主条码',
    minWidth: 100,
    'show-overflow-tooltip': true
  }, {
    prop: 'batchNo',
    label: '批号',
    minWidth: 100,
    'show-overflow-tooltip': true
  }, {
    prop: 'productDate',
    label: '生产日期',
    width: 100
  }, {
    prop: 'expDate',
    label: '有效期',
    width: 100
  }, {
    prop: 'serialNo',
    label: '序列号',
    minWidth: 100,
    'show-overflow-tooltip': true
  }, {
    prop: 'num',
    label: '数量',
    width: 90
  }, {
    prop: 'entryNumd',
    label: '条码图片',
    width: 100
  }
]
// 发货头部信息
export const DELIVER_TOP_INFO = [
  {
    key: 'purchaseOrderCode',
    value: '平台订单编号'
  }, {
    key: 'deliveryOrderCode',
    value: '配送商订单编号'
  },
  {
    key: 'purchaseOrderStatus',
    value: '订单状态'
  }, {
    key: 'createdAt',
    value: '订单提交时间'
  },
  {
    key: 'deliveryCompanyName',
    value: '配送商'
  },
  {
    key: 'productSpecCount',
    value: '品规数'
  },
  {
    key: 'orderDetailCount',
    value: '总数量'
  },
  {
    key: 'sendNumCount',
    value: '配送数量'
  },
  {
    key: 'awaitSendNum',
    value: '待配送数量'
  },
  {
    key: 'orderTotalAmount',
    value: '订单金额'
  },
  {
    key: 'receiveAddress',
    value: '收货地址'
  }, {
    key: 'linkMan',
    value: '联系人'
  }, {
    key: 'linkPhone',
    value: '联系电话'
  }
]
// 发货table列表表头
export const DELIVER_GOODS_COLUMNS = [
  // {
  //   type: 'selection',
  //   fixed: 'left'
  // },
  {
    width: '40',
    prop: 'placeholder',
    fixed: 'left',
    type: 'expand'
  },
  {
    prop: 'deliveryProductCode',
    label: '配送商产品编码',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'deliveryProductName',
    label: '配送商产品名称',
    minWidth: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'productType',
    label: '规格 型号',
    width: 150,
    'show-overflow-tooltip': true,
    formatter: row => `${row.specification || row.productType ? `${row.specification} ${row.productType}` : ''}`
  }, {
    prop: 'manufacturer',
    label: '生产厂家',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'registrationNumber',
    label: '注册证号（或备案号）',
    width: 170,
    'show-overflow-tooltip': true
  }, {
    prop: 'category',
    label: '产品大类',
    width: 90,
    formatter: row => PRODUCT_CATEGORY[row.category]
  },
  {
    prop: 'purchaseNum',
    label: '订单总数量',
    width: 100
  },
  {
    prop: 'sendNum',
    label: '已发货数量',
    width: 100
  },
  {
    prop: 'sweepCount',
    label: '已扫码/待发货数量',
    width: 150,
    formatter: row => `${row.sweepCount ? row.sweepCount : 0}${row.awaitSendNum ? `/${row.awaitSendNum}` : '/' + 0} ${row.unit ? row.unit : ''}`
  },
  {
    prop: 'storageCondition',
    label: '存储条件',
    width: 100
  },
  {
    prop: 'provinceProductCode',
    label: '省平台产品编码',
    width: 150,
    'show-overflow-tooltip': true
  }, {
    prop: 'itemCode',
    label: 'M平台产品编码',
    width: 150
  }, {
    prop: 'action',
    label: '操作',
    width: 100,
    fixed: 'right'
  }

]
